package cn.tedu.spring.bean;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * 注解Autowired: 对象类型的属性值注入
 *
 * 可以用在属性上/set方法上/构造方法上
 */
@Service
public class UserService {
    //简单类型属性值注入
    @Value("login")
    private String name;
    //对象类型属性值注入
    @Autowired
    private UserDao userDao;

//    @Autowired
    public UserService(UserDao userDao) {
        this.userDao = userDao;
    }

//    @Autowired
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public String toString() {
        return "UserService{" +
                "name='" + name + '\'' +
                ", userDao=" + userDao +
                '}';
    }
}
